using System;
using System.Collections.Generic;
using System.Text;
using Spacedash.Logic.Scenario.Cells.Actions;

namespace Spacedash.Logic.Scenario.Cells
{
    /// <summary>
    /// CellData holds special information about a cell in the race scenario, such as a list of meshes that will be drawn on that cell,
    /// or some logic that will be applied when a ship passes over the cell.
    /// </summary>
    public class CellData
    {
        private List<string> meshes = new List<string>();

        /// <summary>
        /// List of meshes that should be drawn on the cell
        /// </summary>
        public List<string> Meshes
        {
            get { return meshes; }
            set { meshes = value; }
        }

        private string shader;
        /// <summary>
        /// Shader that should be used to draw the meshes
        /// </summary>
        public string Shader
        {
            get { return shader; }
            set { shader = value; }
        }
	

        private string name;

        /// <summary>
        /// Name of this CellData
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        /// <summary>
        /// Adds a mesh to the mesh list
        /// </summary>
        /// <param name="m">Mesh to be added</param>
        public void AddMesh(string m)
        {
            meshes.Add(m);
        }

         List<CellAction> collisionActions=new List<CellAction>();
        /// <summary>
        /// List of Actions that will be executed when the ship collides with this mesh
        /// </summary>
        public List<CellAction> CollisionActions { get { return collisionActions; } set { collisionActions = value; } }
        /// <summary>
        /// Adds an action to the list of collision actions
        /// </summary>
        /// <param name="action">Action to add to the list</param>
        public void AddCollisionAction(CellAction action) { collisionActions.Add(action);}
        /// <summary>
        /// Adds a set of actions to the list of collision actions
        /// </summary>
        /// <param name="actions">Actions to add to the list</param>
        public void AddCollisionActions(List<CellAction> actions) { collisionActions.AddRange(actions); }

        /// <summary>
        /// Executes all the actions of the collision action list
        /// </summary>
        /// <param name="ship">Ship colliding with this mesh</param>
        public void ExecuteCollisionActions(Ship ship)
        {
            foreach (CellAction action in collisionActions)
                action.Execute(ship);
        }
    }
}
